# # 使用装饰器实现
# def Singleton(cls):
#     _instance = {}
#
#     def _Singleton(*args, **kargs):
#         if cls not in _instance:
#             _instance[cls] = cls(*args, **kargs)
#         return _instance[cls]
#
#     return _Singleton
#
#
# @Singleton
# class A(object):
#     a = 1
#
#     def __init__(self, x=0):
#         self.x = x
#         a1 = A(2)
#         a2 = A(3)
#         id(a1) == id(a2)
#         True



# # 基于__new__实现
# class Singleton(object):
#     def __new__(cls, *args, **kwargs):
#         if not hasattr(cls, '_instance'):
#             orig = super(Singleton, cls)
#             cls._instance = orig.__new__(cls, *args, **kwargs)
#             return cls._instance
#
#
# class A(Singleton):
#     pass
import datetime

date = datetime.datetime.now()
